# the minimum version of CMake.
cmake_minimum_required(VERSION 3.5.0)
project(openim_napi)

set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})

if(DEFINED PACKAGE_FIND_FILE)
    include(${PACKAGE_FIND_FILE})
endif()

file(COPY "${NATIVERENDER_ROOT_PATH}/sdk/lib/${OHOS_ARCH}/libopenim.so"
    DESTINATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
)

include_directories(${NATIVERENDER_ROOT_PATH}
                    ${NATIVERENDER_ROOT_PATH}/include
                    sdk/include)

aux_source_directory(ohos_utils OHOS_UTILS_SRC)

add_library(openim_napi SHARED openim_napi.cpp ${OHOS_UTILS_SRC})
target_link_libraries(openim_napi PUBLIC ace_napi.z hilog_ndk.z openim uv)
target_link_directories(openim_napi PRIVATE ${NATIVERENDER_ROOT_PATH}/sdk/lib/${OHOS_ARCH})
target_compile_options(openim_napi PRIVATE -ftls-model=global-dynamic)
target_link_options(openim_napi PRIVATE -ftls-model=global-dynamic -Wl,--no-relax -fno-emulated-tls)
